local maxNum = 0

-- Lua 的每个函数(function)中不能超过 200 个本地变量
-- local function main()
--     maxNum = 201 -- main function has more than 200 local variables

--     local fname = "fileA.lua"

--     local configFile = io.open(fname, "w")
--     local iStr = 0
--     for i = 1, maxNum do
--         iStr = tostring(i)

--         configFile:write("local a_"..iStr.."\n")
--     end

--     configFile:write("print(\"ok\")")

--     configFile:flush()
--     configFile:close()
-- end

-- main()

-- upvalue数量不能超过 60 个
-- local function main()
--     maxNum = 61 -- function at line 62 has more than 60 upvalues

--     local fname = "fileB.lua"

--     local configFile = io.open(fname, "w")
--     local iStr = 0
--     for i = 1, maxNum do
--         iStr = tostring(i)

--         configFile:write("local a_"..iStr.."\n")
--     end

--     configFile:write("function func()\n")
--     for i = 1, maxNum do
--         iStr = tostring(i)

--         configFile:write("\ta_"..iStr.." = 0".."\n")
--     end
--     configFile:write("end\n")

--     configFile:write("print(\"ok\")")

--     configFile:flush()
--     configFile:close()
-- end

-- main()

-- 一个控制结构不能超过 32894 个栈
-- local function main()
--     2^15^ + 2^7^ - 1
--     maxNum = 32895 -- control structure too long near '<eof>'

--     local fname = "fileC.lua"

--     local configFile = io.open(fname, "w")
--     local iStr = 0
--     configFile:write("if ")
--     for i = 1, maxNum - 1 do
--         iStr = tostring(i)

--         configFile:write(iStr .. " > 0 and ")
--     end
--     configFile:write(tostring(maxNum) .. " > 0 then\n")
--     configFile:write("\tprint(\"ok\")\n")
--     configFile:write("end\n")

--     configFile:flush()
--     configFile:close()
-- end

-- main()

-- 一个lua文件不能超过 262141 个常量
-- local function main()
    
--     -- 262144 = 2^18^
--     maxNum = 262142 -- constant table overflow

--     local fname = "fileD.lua"

--     local configFile = io.open(fname, "w")
--     local iStr = 0
--     configFile:write("local a = {\n\t")
--     for i = 1, maxNum - 1 do
--         iStr = tostring(i)

--         configFile:write("\""..iStr.."\",")
--     end
--     configFile:write(tostring(maxNum) .. "\n}\n")
--     configFile:write("print(\"ok\")\n")

--     configFile:flush()
--     configFile:close()
-- end

-- main()

-- local function main()
--     local maxNum = "9223372036854775808"

--     local num = tonumber(maxNum)

--     print(num)
-- end

main()
